package com.zz.ecommerce.declareManage.exportB2BDeclare.declareManageQdc;

import com.zz.ecommerce.common.GridRequest;
import com.zz.ecommerce.common.GridResult;
import com.zz.ecommerce.common.bean.qdc.db.TDeclformHeadQdc;
import com.zz.ecommerce.common.constants.DictConstants;
import com.zz.ecommerce.common.constants.TableConstants;
import com.zz.ecommerce.declareManage.common.dao.TDeclformHeadQdcDao;
import com.zz.ecommerce.utils.SessionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 出口B2B申报Controller
 * <p/>
 * Created by fanshilei on 2016/3/28.
 */
@Controller
@RequestMapping("/exportB2B/declareManageQdc")
@Scope("prototype")
public class QdcExportB2BController {

    @Autowired
    private TDeclformHeadQdcDao tDeclformHeadQdcDao;

    /**
     * 申报清单管理
     *
     * @return
     */
    @RequestMapping(value = "declarationForm", method = {RequestMethod.GET})
    public String declarationForm() {
        return "declareManage/exportB2BDeclare/declareManageQdc/declaration_form";
    }

    /**
     * 查询申报清单管理列表
     *
     * @param tDeclformHeadQdc
     * @param request
     * @return
     */
    @RequestMapping("/queryDeclareList")
    @ResponseBody
    public GridResult queryDeclareList(TDeclformHeadQdc tDeclformHeadQdc, GridRequest request,HttpSession session) {
        tDeclformHeadQdc.setOrgId(SessionUtil.getOrganizationId(session));
        tDeclformHeadQdc.setBusinessType(DictConstants.B2B);
        tDeclformHeadQdc.setIeFlag(DictConstants.EXPORT);

        List<TDeclformHeadQdc> list = tDeclformHeadQdcDao.page(TableConstants.T_DECLFORM_HEAD_QDC, tDeclformHeadQdc,
                request.getStart(), request.getEnd(), request.getSortOrder());
        long count = tDeclformHeadQdcDao.count(TableConstants.T_DECLFORM_HEAD_QDC, tDeclformHeadQdc);

        return new GridResult(list, request, count);

    }

}
